﻿@using SCMS.Resource
@model IEnumerable<SCMS.Model.CheckListCategory>
<div class="partialViewCard">
    <div class="partialViewCardHeader">
        <h3>@Resources_morgan.Global_String_ServiceCheckList</h3>
    </div>
    <br />
    @if (Model.Count() > 0)
    {    
        <div id="tablewrapper">
            <div id="tableheader">
                <div class="search">
                    <b>@Resources.Global_String_SearchBy:</b><br />
                    <select id="columns" onchange="sorter.search('query')">
                    </select>
                    <input type="text" id="query" onkeyup="sorter.search('query')" />
                </div>
                <span class="details">
                    <div>
                        @Resources.Global_String_Records <span id="startrecord"></span>-<span id="endrecord"></span>
                        @Resources.Global_String_Of <span id="totalrecords"></span>
                    </div>
                </span>
            </div>
            <br />
            <br />
            <br />
            <table width="98%" align="center" cellpadding="0" cellspacing="0" border="0" id="table"
                class="tinytable">
                <tr class="gridheader">
                    <th rowspan="2">
                        <h3>@Resources.Global_String_Category</h3>
                    </th>
                    <th colspan="2">
                        <h3>@Resources.Global_String_Description</h3>
                    </th>
                    <th rowspan="2">
                        <h3>@Resources.Global_String_Manage</h3>
                    </th>
                </tr>
                <tr class="gridheader">
                    <th>
                        <h3>@Resources.Global_String_Name</h3>
                    </th>
                    <th>
                        <h3>@Resources.Global_String_Description</h3>
                    </th>
                </tr>
                @{int count = 0;}
                @foreach (var item in Model)
                {
                    count = 1 + @item.ServiceCheckLists.Count();
                    <tr class="grideven">
                        <td valign="top"  rowspan=@count>
                            @item.Name
                        </td>
                        <td colspan="2">@item.Description
                        </td>
                        <td align="center">
                            @Ajax.ActionLink(Resources.Global_String_Edit, "EditCategory", new { id = item.Id }, new AjaxOptions
                                {
                                    UpdateTargetId = "popup-page",
                                    LoadingElementId = "popup-loading",
                                    OnBegin = string.Format("ShowDialogue('{0} :: " + item.Name + "')", Resources.Global_String_Edit),
                                    OnSuccess = "CenterPopup"
                                })
                            &nbsp;|&nbsp;
                            @Ajax.ActionLink(Resources.Global_String_Delete, "DeleteCategory", new { CatId = item.Id }, new AjaxOptions
                                {
                                    UpdateTargetId = "SCListDiv",
                                    LoadingElementId = "loading",
                                    Confirm = string.Format(Resources.Global_String_ConfirmDelete, item.Name),
                                    OnSuccess = "if (document.getElementById('table') != null) {initSorter();sorter.size(20);}"
                                })
                        </td>
                    </tr>
                       foreach (var SCL in item.ServiceCheckLists)
                       {
                    <tr class="gridodd">
                        <td>
                            @Html.DisplayFor(modelItem => SCL.Name)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => SCL.Discription)
                        </td>
                        <td align="center">
                            @Ajax.ActionLink(Resources.Global_String_Edit, "Create", new { @sclId = SCL.Id }, new AjaxOptions
                        {
                            UpdateTargetId = "popup-page",
                            LoadingElementId = "popup-loading",
                            OnBegin = string.Format("ShowDialogue('{0} :: " + SCL.Name + "')", Resources.Global_String_Edit),
                            OnSuccess = "CenterPopup"
                        })
                            &nbsp;|&nbsp;
                            @Ajax.ActionLink(Resources.Global_String_Delete, "Delete", new { sclId = SCL.Id }, new AjaxOptions
                        {
                            UpdateTargetId = "SCListDiv",
                            LoadingElementId = "loading",
                            Confirm = string.Format(Resources.Global_String_ConfirmDelete, SCL.Name),
                            OnFailure = "Javascript:AjaxFailure()"
                        })
                        </td>
                    </tr>
                       }
                }
            </table>
            <div id="tablefooter">
                <div id="tablenav">
                    <div>
                        <img src="../../Content/images/pager/first.gif" width="16" height="16" alt="@Resources.Global_String_FirstPage"
                            onclick="sorter.move(-1,true)" />
                        <img src="../../Content/images/pager/previous.gif" width="16" height="16" alt="@Resources.Global_String_PreviousPage"
                            onclick="sorter.move(-1)" />
                        <img src="../../Content/images/pager/next.gif" width="16" height="16" alt="@Resources.Global_String_NextPage"
                            onclick="sorter.move(1)" />
                        <img src="../../Content/images/pager/last.gif" width="16" height="16" alt="@Resources.Global_String_LastPage"
                            onclick="sorter.move(1,true)" />
                    </div>
                    <div>
                        <select id="pagedropdown">
                        </select>
                    </div>
                    <div>
                        <a href="javascript:sorter.showall()">@Resources.Global_String_ViewAll</a>
                    </div>
                </div>
                <div id="tablelocation">
                    <div>
                        <select onchange="sorter.size(this.value)">
                            <option value="5">5</option>
                            <option value="10">10</option>
                            <option value="20" selected="selected">20</option>
                            <option value="50">50</option>
                            <option value="100">100</option>
                        </select>
                        <span>@Resources.Global_String_EntriesPerPage</span>
                    </div>
                    <div class="page">
                        @Resources.Global_String_Page <span id="currentpage"></span>@Resources.Global_String_Of
                        <span id="totalpages"></span>
                    </div>
                </div>
            </div>
        </div> 
    }
    else
    {
        <i>@Resources_morgan.ServiceCheckList_ListView_NoServiceCheckLists</i>
    }
    <br />
</div>
